{extend name="PublicBase/showBase" /}

{block name="body"}
<div class="main">
    <div class="row">
        <div class="col-md-12">
            <section class="tile color transparent-black">
                <div class="tile-header bg-transparent-black-2">
                    <h1>
                        {if condition="$Info eq ''"}
                            {:lang('XtQxXz')}
                        {else /}
                            {:lang('XtQxGx')}
                        {/if}
                    </h1>
                    <div class="controls">
                        <a href="javascript:void(0);" onclick="window.history.back();"><i class="fa fa-arrow-left"></i></a>
                        {if condition="$Info eq ''"}
                            <a href="{:url('SystemGroup/showAdd')}"><i class="fa fa-refresh"></i></a>
                        {else /}
                            <a href="{:url('SystemGroup/showEdit', array('id'=>$Info['group_id']))}"><i class="fa fa-refresh"></i></a>
                        {/if}
                    </div>
                </div>
                <div class="tile-body nopadding">
                    <form class="FormTable" action="" method="post">
                        <div class="tile-body">
                            <div class="row">
                                <div class="form-group col-sm-12">
                                    <label>{:lang('XtQxMc')}</label>
                                    <input type="text" class="form-control" name="group_title" value="{$Info.group_title}" placeholder="{:lang('XtQxMcWk')}" />
                                </div>
                                <div class="form-group col-sm-12">
                                    <label>{:lang('XtQxGz')}</label>
                                    {volist name="Rule" id="Pid1"}
                                        <div class="Check11" style="clear: both;">
                                            <div class="checkbox check-transparent">
                                                <input class="checkboxs Check1" type="checkbox" name="group_rules[]" value="{$Pid1.rule_id}" id="opt{$Pid1.rule_id}" />
                                                <label for="opt{$Pid1.rule_id}">{$Pid1.rule_title}</label>
                                            </div>
                                            {volist name="Pid1['rule_child']" id="Pid2"}
                                                <div class="Check22" style="clear: both;">
                                                    <div class="checkbox check-transparent" style="margin-left: 22px">
                                                        <input class="checkboxs Check2" type="checkbox" name="group_rules[]" value="{$Pid2.rule_id}" id="opt{$Pid2.rule_id}" />
                                                        <label for="opt{$Pid2.rule_id}">{$Pid2.rule_title}</label>
                                                    </div>
                                                    {volist name="Pid2['rule_child']" id="Pid3"}
                                                        <div class="Check33" style="clear: both;">
                                                            <div class="checkbox check-transparent" style="margin-left: 44px">
                                                                <input class="checkboxs Check3" type="checkbox" name="group_rules[]" value="{$Pid3.rule_id}" id="opt{$Pid3.rule_id}" />
                                                                <label for="opt{$Pid3.rule_id}">{$Pid3.rule_title}</label>
                                                            </div>
                                                            {volist name="Pid3['rule_child']" id="Pid4" key="key"}
                                                                <div class="checkbox check-transparent" style="float: left;{if condition="$key eq 1"}margin-left: 66px;{/if}">
                                                                    <input class="checkboxs" type="checkbox" name="group_rules[]" value="{$Pid4.rule_id}" id="opt{$Pid4.rule_id}" />
                                                                    <label for="opt{$Pid4.rule_id}">{$Pid4.rule_title}</label>
                                                                </div>
                                                            {/volist}
                                                        </div>
                                                    {/volist}
                                                </div>
                                            {/volist}
                                        </div>
                                    {/volist}
                                </div>
                                <div class="form-group col-sm-12" style="clear: both;">
                                    <label>{:lang('XtQxZt')}</label>
                                    <select class="chosen-select chosen-transparent form-control" name="group_state">
                                        <option value="1" {eq name="Info['group_state']" value="1"}selected{/eq}>{:lang('XtQxZt1')}</option>
                                        <option value="2" {eq name="Info['group_state']" value="2"}selected{/eq}>{:lang('XtQxZt2')}</option>
                                    </select>
                                </div>
                            </div>
                        </div>
                    </form>
                </div>
                <div class="tile-footer bg-transparent-black-2 rounded-bottom-corners">
                    <div class="row">
                        <div class="col-sm-12 text-center">
                            <button type="button" class="btn btn-{:config('CNF_BTNCOLOR')} ajax-post">{:lang('XtAnTj')}</button>
                        </div>
                    </div>
                </div>
            </section>
        </div>
    </div>
</div>
{/block}

{block name="script"}
    <script>
        +function($){
            var rules = [{$Info.group_rules}];
            $('.checkboxs').each(function(){
                if($.inArray(parseInt(this.value),rules) > -1){
                    $(this).prop('checked',true);
                }
                if(this.value==''){
                    $(this).closest('.checkbox').remove();
                }
            });

            $('.Check1').on('change',function(){
                $(this).closest('.Check11').find('.checkbox').find('input').prop('checked',this.checked);
            });
            $('.Check2').on('change',function(){
                $(this).closest('.Check22').find('.checkbox').find('input').prop('checked',this.checked);
            });
            $('.Check3').on('change',function(){
                $(this).closest('.Check33').find('.checkbox').find('input').prop('checked',this.checked);
            });
        }(jQuery);
    </script>
{/block}
      
